package com.youkeda.meetingroom.service.impl;

import com.youkeda.meetingroom.dao.mapper.MrCompanyMapper;
import com.youkeda.meetingroom.model.Company;
import com.youkeda.meetingroom.model.Result;
import com.youkeda.meetingroom.service.CompanyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * CompanyServiceImpl的注释
 *
 * @author: Awake
 * @date: 2019-07-03 17:35
 **/
@Service
public class CompanyServiceImpl implements CompanyService {

    @Resource
    MrCompanyMapper mrCompanyMapper;

    /**
     * 获取公司信息
     *
     * @param companyId 公司主键
     * @return 公司信息
     */
    @Override
    public Result getCompany(String companyId) {

        Result result = new Result();

        if(mrCompanyMapper.selectByPrimaryKey(companyId).getId() != null){
            Company company = new Company();
            company.setId(mrCompanyMapper.selectByPrimaryKey(companyId).getId());
            company.setGmtCreated(mrCompanyMapper.selectByPrimaryKey(companyId).getGmtCreated());
            company.setGmtModified(mrCompanyMapper.selectByPrimaryKey(companyId).getGmtModified());
            company.setName(mrCompanyMapper.selectByPrimaryKey(companyId).getName());
            result.setSuccess(true);
            result.setData(company);
        }else {
            result.setSuccess(false);
            result.setErrorMessage("未找到相应的公司");
        }
        return result;
    }

}
